<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ConfigureItems extends Model
{

    protected $table = 'configure_items';

    protected $primaryKey = 'item_id';

    public $timestamps = false;

    public $incrementing = false;

    /**
     * 查询分组id查询选项数据
     * @param int $group_id 分组id
     * @return array
     */
    public static function getItems($group_id)
    {

        $items = self::select('item_id', 'item_name')->where(['group_id' => $group_id ,'useFlg' => 1])->get()->toArray();
        if ($items) {
            $data = [];
            foreach ($items as &$item) {
                $data[] = [
                    'id' => $item['item_id'],
                    'name' => $item['item_name']
                ];
            }
            return $data;
        } else {
            return [];
        }

    }

}
